<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%><%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<form id="stepForm" action="/post/index-step-3.html" method="post">
    <input type="hidden" name="task_id" id="task_id" value="559771" />
	<ul class="dingdan" id="dingdan">
    	<li class="th clearfix">
        	<p class="tp1">收费项目</p>
            <p class="tp2"><span class="hep">获得元宝</span><a class="help" href="#" target="_blank"></a></p>

            <p class="tp3">价格</p>
            <p class="tp4">操作</p>
        </li>
        <li class="clearfix">
        	<p class="tp1 tp5">12345</p>
            <p class="tp2 tp5">200</p>
                        <p class="tp3 tp5"><strong class="orange1 price" id="projectPrice">200.00元</strong> (赏金托管)</p>

            <p class="tp4"><a href="/post/index-step-1-tid-559771.html" class="dels">返回编辑</a></p>
        </li>
		<input id="service" name="service" type="hidden" value=""/>
    </ul>
	<ul>
	<li><br />&nbsp;&nbsp;<a name="kaipiao" id="kaipiao" value="559771" style="background: url(http://s.zbjimg.com/p/task/img/fapiao.gif) no-repeat 0 1px; padding: 3px 0 0 20px; line-height: 20px; color:#1C66B4; cursor: pointer;" />索取发票</a></li>
	</ul>
    <div class="yue">

    	<p>  <span class="zj">总价:<u class="orange1" id="allprice">200</u>元</span></p>
    	<p class="mt10"><!--<a class="at_but b_1_b" id="djq_but" href="javascript:void(0);"><u></u>使用代金券</a>--> <a class="at_but b_1_y" id="submit" href="javascript:void(0);"><u></u>确定订单</a></p>
    </div>
</form>
<div class="tjfu">
    	<p class="titc"><span>推荐服务</span> 让你的任务效果更好，你更省心！</p>

        <ul id="fuwu">
        	<!--<li class="clearfix" sid="8"><p><span class="title">服务套餐</span>： <span class="gray3">标题加粗 + 标题高亮 + 任务推广 </span><u>为您节省10元！<strong>价格：<s class="number">88</s>元</strong></u></p><a href="####" class="gwc"></a></li>
        	<li class="clearfix" sid="3"><p><span class="title">标题加粗</span>： <span class="gray3">任务标题更显眼 </span><u><strong>价格：<s class="number">20</s>元</strong></u></p><a href="javascript:void(0);" class="gwc"></a></li>
			<li class="clearfix" sid="7"><p><span class="title">标题高亮</span>： <span class="gray3">任务标题更显眼 </span><u><strong>价格：<s class="number">20</s>元</strong></u></p><a href="javascript:void(0);" class="gwc"></a></li>-->
			<li class="clearfix" sid="6"><p><span class="title">任务推广</span>： <span class="gray3">在网站各推荐位显示你的任务 <a class="bule1" href="http://s.zbjimg.com/p/task/img/coli.png" style="margin:0" target="_blank">图示说明</a> </span><u><strong>价格：<s class="number">58</s>元</strong></u></p><a href="javascript:void(0);" class="gwc"></a></li>
			<li class="clearfix" sid="4"><p><span class="title">隐藏任务</span>： <span class="gray3">屏蔽搜索引擎，仅猪八戒网会员可见 </span><u><strong>价格：<s class="number">50</s>元</strong></u></p><a href="javascript:void(0);" class="gwc"></a></li>

			<li class="clearfix" sid="5"><p><span class="title">隐藏交稿</span>： <span class="gray3">所有稿件只有买家可见(中标稿件除外) </span><u><strong>价格：<s class="number">58</s>元</strong></u></p><a href="javascript:void(0);" class="gwc"></a></li>
		</ul>
    </div>
<div id="djq_box">
	<div class="djq">
    	<p class="tit"><strong>请输入代金券卡号和密码</strong></p>

    	<p class="clearfix"><span class="at_wl_lt gray2">卡号：</span><span class="at_text t_1_d kaid"><input value="" maxlength="18"/></span></p>
    	<p class="clearfix"><span class="at_wl_lt gray2">密码：</span><span class="at_text t_1_d kspass"><input value="" maxlength="18" type="password"/></span></p>
    </div>
</div>
<div id="opts_box" style="display:none">
    <table width="95%" border="0" cellspacing="0" cellpadding="0" height="400" class="list_tab gray2 mb10" align="center" style="margin:0 auto;">
   <tr>
        <td style="width:80px"><div id="u8_rtf">抬头：</div></td>

        <td><input type="text" name="title" size="40"  value="12345"/>(请填写公司名称或者姓名)</td>
  </tr>
   <tr>
        <td style="width:80px">开票内容：</td>
        <td><select name="content"><option value="0" selected="selected">设计费</option><option value="1">网络服务费</option><option value="2">策划费</option></select></td>
  </tr>

   <tr>
        <td style="width:80px">证件类型：</td>
        <td><select name="type"><option value="0" selected="selected">身份证号码（个人）</option><option value="1">组织机构代码</option><option value="2">纳税人识别号</option></select></td>
  </tr>
  <tr>
      <td style="width:80px">证件号码：</td>

      <td><input type="text" name="idnumber"/></td>
  </tr>
 <tr>
      <td><strong>邮寄资料：</strong></td>
      <td></td>
  </tr>
  <tr>
    <td>联系人：</td>

    <td><input type="text" name="lianxiren"  value=""/></td>
  </tr>
  <tr>
    <td>邮寄地区：</td>
    <td>
        <select class="ld-select-1" id="province" name="province" onChange="getcity(this.value)">
        <option value="">---请选择省份---</option>
        </select>

        <select class="ld-select-1" id="city" name="city" onChange="gettown(this.value)">
        <option value="">---请选择城市---</option>
        </select>
        <select class="ld-select-1" id="town" name="town">
        <option value="">---请选择地区---</option>
        </select>
    </td>
  </tr>

  <tr>
      <td>街道地址：</td>
      <td><input type="text" name="address"  size="40" value=""/></td>
  </tr>
  <tr>
      <td>邮政编码：</td>
      <td><input type="text" name="zip" value=""/></td>
  </tr>

  <tr>
      <td>联系电话：</td>
      <td><input type="text" name="tel" value=""/><input type="hidden" name="taskid" id="taskid" value="559771" /></td>
  </tr>
</table>
</div>
<%--

<script>
var projectPrice = $("#projectPrice").text();
var djq_button = $("#djq_but");
if(parseInt(projectPrice.replace(/[^\d]*/,"")) >= 500) djq_button.show();
else djq_button.hide();

(function(){
	var service, svtitle, teamcon, current, index, count, cpgroup;
	service = $("#fuwu>li");
	_submit = $("#submit");
	form = $("#stepForm");
	cpgroup = "li[sid='3'],li[sid='7'],li[sid='6']";	//查找产品套餐包含服务的语句
	svtitle = service.eq(0).parent().parent().children("p.titc");
	teamcon = $("#dingdan");
	current = $("#service");
	count = $("#allprice");
	service.hover(function(){
		$(this).addClass("sect")
	}, function() {
		$(this).removeClass("sect")
	});
	service.find("a.gwc").click(function() {
		_dbclick_call_(service.find("a.gwc").index(this));
	})
	service.dblclick(function() {
		_dbclick_call_(service.index(this));
	})
	function _dbclick_call_(i) {
		index = i;
		var price = parseFloat(service.eq(index).find("s.number").text());
		var ingot = Math.floor(price * 1);
		var name = service.eq(index).find("span.title").text();
		var sid  = service.eq(index).attr("sid");
		addTeams(sid, name, ingot, price, index);
	}
	//确认订单
	_submit.click(function(){
		at_loading.show();
		//alert(form.attr("action"));return;
		$.ajax({
			url: form.attr("action"),
			data:form.serialize(),
			success:function(data, textStatus) {
				at_loading.hide();
				if(data.state == 1) {
					eval(data.callback);
				} else {
					at_infoTrace.show(data.msg,"e");
				}
			},
			error:function(XMLHttpRequest, textStatus, errorThrown) {
				at_loading.hide();
				at_infoTrace.show("异常错误","e");
			}
		});
	});
	
	function addTeams(sid, name, ingot, price, index) {
		var li = "", obj, del;
			li+= "<li class=\"clearfix\" sid=\""+sid+"\">";
        	li+= "<p class=\"tp1 tp5\">"+name+"</p>";
            li+= "<p class=\"tp2 tp5\">"+ingot+"</p>";
            li+= "<p class=\"tp3 tp5\"><strong class=\"orange1 price\">"+price+" 元</strong></p>"
            li+= "<p class=\"tp4\"><a href=\"####\" class=\"dels\">移除</a></p>"
        	li+= "</li>";
		teamcon.append(li);
		removeService(index, sid);
		setCount();
		setCurrent(sid, "add");
		if(sid == "s00") djq_button.hide();
		obj = teamcon.children("li[sid='"+sid+"']");
		del = obj.find("a.dels");
		del.click(function(){ 
			removeTeams(obj, sid);
			setCount();
			setCurrent(sid, "remove");
		});
	}
	
	function addService(sid) {
		service.filter("li[sid='"+sid+"']").show();
		if(!checkAllNone()) svtitle.show();
	}
	
	function removeService(index, sid) {
		service.eq(index).hide();
		if(checkAllNone()) svtitle.hide();
		if(sid == "8") useGroup();
	}
	
	function removeTeams(obj, sid) {
		obj.remove();
		addService(sid);
		if(sid == "s00") djq_button.show();
		if(sid == "8") service.filter(cpgroup).show();
	}
	
	function useGroup() {	//使用套餐
		service.filter(cpgroup).hide();		//隐藏相关服务项
		teamcon.children(cpgroup).remove();	//隐藏已选项
	}
	
	function setCount(){ 	//计算总价
		var price = teamcon.find("li strong.price");
		var money = 0;
		price.each(function() {
			money += parseFloat($(this).text().replace(/[^\d\.\-\+]*/,""));
		})
		count.text(money);
	}
	
	function setCurrent(sid, method) {	//保存已选
		current.val(current.val().replace(sid+",",""));
		if (sid == 8) {
			current.val(current.val().replace("3,",""));
			current.val(current.val().replace("6,",""));
			current.val(current.val().replace("7,",""));
		}
		if (method == "add") current.val(current.val() + sid + ",");
	}
	
	/* 检测是否全部服务都被选择，如果是则返回true */
	function checkAllNone() {
		var state = true;
		for(var i=0; i<service.length; i++) {
			if(service.eq(i).css("display") != "none") state = false;
		}
		return state;
	}
	
	/* 使用代金券 */
	(function(){
		var traces = new at_trace();
		var info_t = new at_trace();
		var djqcon, msgcon, kaid, pass;
		
		traces.setContact(
			"代金券", null,
			[
				traces.getButton("提交", "yellow", function(){
					if(kaid.val().replace(/\s*/,"") == "" || pass.val().replace(/\s*/,"") == "") {
						showMsg("卡号或密码不能为空");
						return;
					}
					at_loading.show();
					$.ajax({
						url: "http://127.0.0.1/cs.php",
						data: "mode=djq&kid="+kaid.val()+"&pass="+pass.val(),
						success: function(msg) {
							at_loading.hide();
							if(parseInt(msg.state) == 1) {
								traces.setDisplay("hide");
								/* 写入代金券 */
								//sid, name, ingot, price 
								addTeams("s00", "代金券", 0, -50);
							} else showMsg("卡号或密码有误，请返回重新输入!");
						}
					})
				}),
				traces.getButton("查看已有代金券", "href", function(){}),
				traces.getButton("怎样获得？", "href", function(){})
			]
		);
		info_t.setContact(
			"系统提示", 
			"<div class=\"at_trace_if clearfix\"><u class=\"at_msg m_1_i\"></u><p class=\"at_trace_if_c ml15\"></p></div>",
			[
				traces.getButton("重新输入", "gray", function(){
					traces.setDisplay("show");
					info_t.setDisplay("hide");
				})
			]
		);
		
		traces.appendContact($("#djq_box").html());
		traces.setWidth(320);
		info_t.setWidth(350);
		
		djqcon = traces.getThis().find("div.djq");
		kaid = djqcon.find("span.kaid input");
		pass = djqcon.find("span.kspass input");
		
		msgcon = info_t.getThis().find("p.at_trace_if_c");
		
		kaid.focus(function(){ changeState(this, "t_1_i")
		}).blur(function(){ changeState(this, "t_1_d") });
		pass.focus(function(){ changeState(this, "t_1_i")
		}).blur(function() { changeState(this, "t_1_d") });
		
		function showMsg(msg) {
			msgcon.html(msg);
			info_t.setDisplay("show");
			traces.setDisplay("hide");
		}
		
		function changeState(obj, stateClass) {
			$(obj).parent().attr("className", "at_text "+stateClass);
		}
		
		djq_button.click(function(){
			at_infoTrace.show("暂不支持使用代金券","i");
			//开始打开代金券窗口
			//traces.setDisplay("show");
		});
	})();
	
})();

$("#kaipiao").click(function(){
    var $this=$(this);
    var traces=new at_trace();
    var tid=$this.attr("value");
    if($("#kaipiao").val()>=0){
        at_loading.show();
        traces.setContact("填写开票基本信息","<div id='opts_box2'>"+$("#opts_box").html()+"</div>",
            [traces.getButton("确定开票", "yellow", function(){
                var traceBox=traces.getThis();
                var title=traceBox.find("input[name='title']").val();
                var content=traceBox.find("select[name='content']").val();
                var type=traceBox.find("select[name='type']").val();
                var idnumber=traceBox.find("input[name='idnumber']").val();
                var lianxiren=traceBox.find("input[name='lianxiren']").val();
                var province=traceBox.find("select[name='province']").val();
                var city=traceBox.find("select[name='city']").val();
                var town=traceBox.find("select[name='town']").val();
                var address=traceBox.find("input[name='address']").val();
                var zip=traceBox.find("input[name='zip']").val();
                var tel=traceBox.find("input[name='tel']").val();
                $.ajax({
                    type:"POST",
                    url:"/billing/ajax-type-2.html",
                    data:"taskid="+tid+"&title="+title+"&content="+content+"&type="+type+"&idnumber="+idnumber+"&lianxiren="+lianxiren+"&province="+province+"&city="+city+"&town="+town+"&address="+address+"&zip="+zip+"&tel="+tel,
                    success:function(data,textStatus){
                       if(data.state==1){
                           traces.setDisplay('hide');
                           at_infoTrace.show(data.msg,'o');
                           $this.text("编辑发票");
                       }else if(data.state==-1){
                           at_infoTrace.show(data.msg,'e');
                       }else if(data.state==-2){
                         at_infoTrace.show(data.msg,'o');
					     traces.setDisplay('hide');
					   }
                    }
                  });
                }),
            traces.getButton("取消", "gray","close")
        ]);
        at_loading.hide();
        traces.setWidth(550);
        traces.setDisplay('show');
        $.ajax({
            type:"POST",
            url:"/billing/ajax-type-1.html",
            data:"tid="+tid,
            success:function(data,textStatus){
               if(data.state==1){
                  var traceBox=traces.getThis();
                  traceBox.find("input[name='title']").val(data.title);
				  traceBox.find("select[name='content']").val(data.b_content);
			      traceBox.find("select[name='type']").val(data.type);
	              traceBox.find("input[name='idnumber']").val(data.idnumber);
	              traceBox.find("input[name='lianxiren']").val(data.lianxiren);
	              traceBox.find("input[name='address']").val(data.address);
	              traceBox.find("input[name='zip']").val(data.zip);
	              traceBox.find("input[name='tel']").val(data.tel);
	              traceBox.find("select[name='province']").val(data.province);
	              traceBox.find("select[name='city']").val(data.city);
	              traceBox.find("select[name='town']").val(data.town);
                  
	              //加载地区
                  getprovince('1',data.province);
                  getcity(data.province,data.city);
                  gettown(data.city,data.town);
               }else{
                 at_loading.hide();
                 at_infoTrace.show(data.msg,"e");
               }
            },
            error:function(XMLHttpRequest, textStatus, errorThrown){
               at_loading.hide();
               at_infoTrace.show("异常错误！","e");
            }
        });    
    }
});
</script> --%>